package com.tool.btn;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.swing.SwingConstants;

import org.come.Frame.*;
import org.come.Jpanel.*;
import org.come.bean.NpcComposeBean;
import org.come.bean.SuitOperBean;
import org.come.bean.WitchComposeBean;
import org.come.entity.Goodstable;
import org.come.entity.PartJade;
import org.come.model.LianHua;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.starcard.JframeStarCardMain;
import org.come.until.*;

import com.tool.role.RoleData;

public class RefineOperBtn extends MoBanBtn {

    private NewRefiningJpanel NrJpanel;
    private RefinersJpanel rJpanel;
    private RefiningEquiJpanel eJpanel;
    private RefiningEquiJpanel2 eJpanel2;
    private TestSetupJpanel tJpanel;
    private int cao;
    private HallucinationJpanel hallucinationJpanel;
    /** 0保留 1替换 2再次炼化 */
    public RefineOperBtn(String iconpath, int type, Color[] colors, Font font, NewRefiningJpanel nrJpanel, int cao,
            String text) {
        super(iconpath, type, colors);
        setText(text);
        setFont(font);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        NrJpanel = nrJpanel;
        this.cao = cao;
    }
    public RefineOperBtn(String iconpath, int type, HallucinationJpanel hallucinationJpanel, int cao) {
        // TODO Auto-generated constructor stub
        super(iconpath, type);
        this.hallucinationJpanel = hallucinationJpanel;
        this.cao = cao;
    }
    /** 3下拉框展示与隐藏 */
    public RefineOperBtn(String iconpath, int type, NewRefiningJpanel nrJpanel, int cao) {
        super(iconpath, type);
        NrJpanel = nrJpanel;
        this.cao = cao;
    }

    /** 0 ?按钮字在改变 */
    public RefineOperBtn(String iconpath, int type, Color[] colors, Font font, RefinersJpanel rJpanel, int cao,
            String text) {
        super(iconpath, type, colors);
        setText(text);
        setFont(font);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.rJpanel = rJpanel;
        this.cao = cao;
    }

    /** 0 ?按钮字在改变 */
    public RefineOperBtn(String iconpath, int type, Color[] colors, Font font, RefiningEquiJpanel eJpanel, int cao,
            String text) {
        super(iconpath, type, colors);
        setText(text);
        setFont(font);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.eJpanel = eJpanel;
        this.cao = cao;
    }






    /** 0保留 1替换 2再次炼化 */
//    public RefineOperBtn(byte[] iconByte,String fileName, int type, Color[] colors, Font font, NewRefiningJpanel nrJpanel, int cao,
//                         String text) {
//        super(iconByte,fileName, type, colors);
//        setText(text);
//        setFont(font);
//        setVerticalTextPosition(SwingConstants.CENTER);
//        setHorizontalTextPosition(SwingConstants.CENTER);
//        NrJpanel = nrJpanel;
//        this.cao = cao;
//    }

    /** 3下拉框展示与隐藏 */
//    public RefineOperBtn(byte[] iconByte,String fileName, int type, NewRefiningJpanel nrJpanel, int cao) {
//        super(iconByte,fileName, type);
//        NrJpanel = nrJpanel;
//        this.cao = cao;
//    }

    /** 0 ?按钮字在改变 */
//    public RefineOperBtn(byte[] iconByte,String fileName, int type, Color[] colors, Font font, RefinersJpanel rJpanel, int cao,
//                         String text) {
//        super(iconByte,fileName, type, colors);
//        setText(text);
//        setFont(font);
//        setVerticalTextPosition(SwingConstants.CENTER);
//        setHorizontalTextPosition(SwingConstants.CENTER);
//        this.rJpanel = rJpanel;
//        this.cao = cao;
//    }

    /** 0 ?按钮字在改变 */
    public RefineOperBtn(String iconpath, int type, Color[] colors, Font font, RefiningEquiJpanel2 eJpanel2, int cao,
                         String text) {
        super(iconpath, type, colors);
        setText(text);
        setFont(font);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.eJpanel2 = eJpanel2;
        this.cao = cao;
    }

    public RefineOperBtn(String iconpath, int type, TestSetupJpanel testSetupJpanel, int cao) {
		// TODO Auto-generated constructor stub
    	super(iconpath, type);
        tJpanel = testSetupJpanel;
        this.cao = cao;
    }

	@Override
    public void chooseyes() {
        // TODO Auto-generated method stub

    }

    @Override
    public void chooseno() {
        // TODO Auto-generated method stub

    }

    @Override
    public void nochoose(MouseEvent e) {
        // TODO Auto-generated method stub
        if (NrJpanel != null) {
            /** 0保留 1替换 2再次炼化 */
            if (cao == 0) {
                RefiningEquiJpanel EJpanel = WorkshopRefiningJframe.getWorkshopRefiningJframe()
                        .getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel();
                RefiningEquiJpanel2 EJpanel2 = WorkshopRefiningJframe.getWorkshopRefiningJframe()
                        .getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel2();
                String v = RefiningUtil.detection(EJpanel.goods, EJpanel.getType());
                if (v.equals("点翠")){
                    FormsManagement.HideForm(120);
                }else if (v.equals("点翠强化")){
                    if (DianQJframe.getDdianQJframe().getDianJpanel().clBean!=null){
                        String senmes = Agreement.extrAttrOperAgreement(GsonUtil.getGsonUtil().getgson()
                                .toJson(DianQJframe.getDdianQJframe().getDianJpanel().clBean));
                        SendMessageUntil.toServer(senmes);
                        DianQJframe.getDdianQJframe().getDianJpanel().TH(DianQJframe.getDdianQJframe().getDianJpanel().clBean);
                    }
                    FormsManagement.HideForm(127);
                }else
                    FormsManagement.HideForm(11);
            }
//            {
//                FormsManagement.HideForm(11);
//            }
            else if (cao == 1) {
                if (NrJpanel.clBean != null) {
                    String senmes = Agreement.extrAttrOperAgreement(GsonUtil.getGsonUtil().getgson()
                            .toJson(NrJpanel.clBean));
                    SendMessageUntil.toServer(senmes);
                    NrJpanel.TH(NrJpanel.clBean);
                } else {
                    FormsManagement.HideForm(11);
                }

                if (DdianJframe.getDdianJframe().getDianJpanel().clBean!=null){
                    String senmes = Agreement.extrAttrOperAgreement(GsonUtil.getGsonUtil().getgson()
                            .toJson(DdianJframe.getDdianJframe().getDianJpanel().clBean));
                    SendMessageUntil.toServer(senmes);
                    DdianJframe.getDdianJframe().getDianJpanel().TH(DdianJframe.getDdianJframe().getDianJpanel().clBean);
                }
                if (DianQJframe.getDdianQJframe().getDianJpanel().clBean!=null){
                    String senmes = Agreement.extrAttrOperAgreement(GsonUtil.getGsonUtil().getgson()
                            .toJson(DianQJframe.getDdianQJframe().getDianJpanel().clBean));
                    SendMessageUntil.toServer(senmes);
                    DianQJframe.getDdianQJframe().getDianJpanel().TH(DianQJframe.getDdianQJframe().getDianJpanel().clBean);
                }

            } else if (cao == 2) {
                if (NrJpanel.leixing == 1) {
                    RefinersJpanel rJpanel = WorkshopRefiningJframe.getWorkshopRefiningJframe()
                            .getWorkshopRefiningJpanel().getCardJpanel().getRefinersJpanel();
                    String v = rJpanel.detection();
                    if (v.equals("炼器")) {
                        cao1(rJpanel.goods, rJpanel.money, 1);
                    }
                } else if (NrJpanel.leixing == 0) {
                    RefiningEquiJpanel EJpanel = WorkshopRefiningJframe.getWorkshopRefiningJframe()
                            .getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel();
                    RefiningEquiJpanel2 EJpanel2 = WorkshopRefiningJframe.getWorkshopRefiningJframe()
                            .getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel2();

                    String v = RefiningUtil.detection(EJpanel.goods, EJpanel.getType());
                    String v2 = RefiningUtil.detection(EJpanel2.goods, EJpanel2.getType());
                    if (v.equals("炼化装备") || v.equals("炼化仙器") || v.equals("炼化神兵"))
//                        if (v.equals("炼化装备") || v.equals("巫铸") ||  v.equals("炼化仙器") || v.equals("炼化神兵"))
                        {
                        cao1(EJpanel.goods, EJpanel.money, 4);
                    }

                    else if (v2.equals("点翠")){
                        caozuo5(EJpanel2.goods, EJpanel2.money,v2);
                    }else if (v2.equals("点翠强化")){
                        if (DianQJframe.getDdianQJframe().getDianJpanel().clBean!=null){
                            String senmes = Agreement.extrAttrOperAgreement(GsonUtil.getGsonUtil().getgson()
                                    .toJson(DianQJframe.getDdianQJframe().getDianJpanel().clBean));
                            SendMessageUntil.toServer(senmes);
//                            DianQJframe.getDdianQJframe().getDianJpanel().TH(DianQJframe.getDdianQJframe().getDianJpanel().clBean);
                        }
                        caozuo5(EJpanel2.goods, EJpanel2.money,v2);
                    }

                } else if (NrJpanel.leixing == 2 || NrJpanel.leixing == 3) {
                    JframeStarCardMain.getJframeSummonEquipMain().getJpanelStarCardMain().caoZuoStarCard();
                } else if (NrJpanel.leixing == 4) {
                    NrJpanel.selectArenaIndex();
                }
            } else if (cao == 3) {
                NrJpanel.showArenaDownLab();
            }
        } else if (rJpanel != null) {
            if (cao == 0) {
                String v = rJpanel.detection();
                if (v.equals("炼器")) {
                    String value = AccessSuitMsgUntil.getExtra(rJpanel.goods[0].getValue(), "炼器属性");
                    NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel().show(value, 1, true);
                } else if (v.equals("?")) {
                    ZhuFrame.getZhuJpanel().addPrompt2("公式不对");
                } else if (v.equals("清除")) {
                    cao1(rJpanel.goods, rJpanel.money, 3);
                } else if (v.equals("开光")) {
                    cao1(rJpanel.goods, rJpanel.money, 0);
                }
            }
        } else if (eJpanel != null) {
            String v = RefiningUtil.detection(eJpanel.goods, eJpanel.getType());
            if (v.equals("炼化装备") || v.equals("炼化仙器") || v.equals("炼化神兵")) {
                String value = AccessSuitMsgUntil.getExtra(eJpanel.goods[0].getValue(), "炼化属性");
                NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel().show(value, 0, true);
            } else if (v.equals("装备培养") || v.equals("装备升级") || v.equals("装备重铸")) {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < eJpanel.money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                    return;
                }
                palEquipUpgradeOrCultivate(eJpanel.goods, v);
            } else {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < eJpanel.money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                    return;
                }
                List<BigDecimal> rgids = new ArrayList<>();
                int size = 0;
                int p = -1;
                for (int i = 0; i < eJpanel.goods.length; i++) {
                    if (eJpanel.goods[i] == null) {
                        continue;
                    }
                    size++;
                    p = i;
                    if (eJpanel.goods[i].getGoodlock() == 1) {
                        ZhuFrame.getZhuJpanel().addPrompt("该物品已被加锁");
                        return;
                    }
                    if (GoodsListFromServerUntil.isExist(eJpanel.goods[i])) {
                        return;
                    }
                    int sum = 1;
                    for (int j = 0; j < rgids.size(); j++) {
                        if (eJpanel.goods[i].getRgid().compareTo(rgids.get(j)) == 0) {
                            sum++;
                        }
                    }
                    if (sum > eJpanel.goods[i].getUsetime()) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                        return;
                    }
                    rgids.add(eJpanel.goods[i].getRgid());
                }
                if (p + 1 != size) {
                    ZhuFrame.getZhuJpanel().addPrompt2("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
                    return;
                }
                if (v.equals("佩饰培养") || v.equals("一键培养")) {
                    cao3(eJpanel.goods, eJpanel.money, rgids);
                } else if (v.equals("秘石合成")) {
                    cao4(eJpanel.goods, eJpanel.money, v, rgids);
                }
                else if (v.equals("点翠")){
                    if (eJpanel.goods[0].getValue()!=null){
                        String[]mes=eJpanel.goods[0].getValue().split("\\|");
                        /*if (mes.length<=11){
                            ZhuFrame.getZhuJpanel().addPrompt2("#Y当前装备没有点翠！请先获取点翠");
                            return;
                        }*/
                        String value = AccessSuitMsgUntil.getExtra(eJpanel.goods[0].getValue(), "点翠属性");
                        DdianJframe.getDdianJframe().getDianJpanel().show(value,0,value != null);
                    }
                    // caozuo5(eJpanel.goods,eJpanel.money,v,rgids);
                }else if (v.equals("点翠强化")){
                    if (eJpanel.goods[0].getValue()!=null){
                        String value = AccessSuitMsgUntil.getExtra(eJpanel.goods[0].getValue(), "点翠属性");
                        if (value==null){
                            ZhuFrame.getZhuJpanel().addPrompt2("#Y当前装备没有点翠！请先获取点翠");
                            return;
                        }
                        DianQJframe.getDdianQJframe().getDianJpanel().show(value,0,false);
                        //  DdianJframe.getDdianJframe().getDianJpanel().show(value,0, value != null);
                    }


                }
                else {
                    cao2(eJpanel.goods, eJpanel.money, v, rgids);
                }
            }
        }else if (eJpanel2 != null) {
            String v2 = RefiningUtil.detection(eJpanel2.goods, eJpanel2.getType());
            if (v2.equals("炼化装备") || v2.equals("炼化仙器") || v2.equals("炼化神兵")) {
                String value = AccessSuitMsgUntil.getExtra(eJpanel.goods[0].getValue(), "炼化属性");
                NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel().show(value, 0, true);
            } else if (v2.equals("装备培养") || v2.equals("装备升级") || v2.equals("装备重铸")) {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < eJpanel.money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                    return;
                }
                palEquipUpgradeOrCultivate(eJpanel2.goods, v2);
            } else {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < eJpanel2.money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                    return;
                }
                List<BigDecimal> rgids = new ArrayList<>();
                int size = 0;
                int p = -1;
                for (int i = 0; i < eJpanel2.goods.length; i++) {
                    if (eJpanel2.goods[i] == null) {
                        continue;
                    }
                    size++;
                    p = i;
                    if (eJpanel2.goods[i].getGoodlock() == 1) {
                        ZhuFrame.getZhuJpanel().addPrompt("该物品已被加锁");
                        return;
                    }
                    if (GoodsListFromServerUntil.isExist(eJpanel2.goods[i])) {
                        return;
                    }
                    int sum = 1;
                    for (int j = 0; j < rgids.size(); j++) {
                        if (eJpanel2.goods[i].getRgid().compareTo(rgids.get(j)) == 0) {
                            sum++;
                        }
                    }
                    if (sum > eJpanel2.goods[i].getUsetime()) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                        return;
                    }
                    rgids.add(eJpanel2.goods[i].getRgid());
                }
                if (p + 1 != size) {
                    ZhuFrame.getZhuJpanel().addPrompt2("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
                    return;
                }
                if (v2.equals("佩饰培养") || v2.equals("一键培养")) {
                    cao3(eJpanel2.goods, eJpanel2.money, rgids);
                } else if (v2.equals("秘石合成")) {
                    cao4(eJpanel2.goods, eJpanel2.money, v2, rgids);
                }
                else if (v2.equals("点翠")){
                    if (eJpanel2.goods[0].getValue()!=null){
                        String[]mes=eJpanel2.goods[0].getValue().split("\\|");
                        /*if (mes.length<=11){
                            ZhuFrame.getZhuJpanel().addPrompt2("#Y当前装备没有点翠！请先获取点翠");
                            return;
                        }*/
                        String value = AccessSuitMsgUntil.getExtra(eJpanel2.goods[0].getValue(), "点翠属性");
                        DdianJframe.getDdianJframe().getDianJpanel().show(value,0,value != null);
                    }
                     caozuo5(eJpanel2.goods,eJpanel2.money,v2);
                }else if (v2.equals("点翠强化")){
                    if (eJpanel2.goods[0].getValue()!=null){
                        String value = AccessSuitMsgUntil.getExtra(eJpanel2.goods[0].getValue(), "点翠属性");
                        if (value==null){
                            ZhuFrame.getZhuJpanel().addPrompt2("#Y当前装备没有点翠！请先获取点翠");
                            return;
                        }
                        DianQJframe.getDdianQJframe().getDianJpanel().show(value,0,false);
                        //  DdianJframe.getDdianJframe().getDianJpanel().show(value,0, value != null);
                    }


                }
                else {
                    cao2(eJpanel2.goods, eJpanel2.money, v2, rgids);
                }
            }
        }else if (tJpanel != null) {
        	if(cao == 3) {
        		tJpanel.showArenaDownLab();
        	}
        }else if (hallucinationJpanel!=null) {
            if(cao == 10101) {
                hallucinationJpanel.showArenaDownLab();
            }
        }
    }

    /** 0开光 1炼器 3清除炼器 4炼化 */
    public boolean cao1(Goodstable[] goods, BigDecimal money, int type) {
        NewRefiningJpanel NrJpanel = null;
        if (this.NrJpanel == null) {
            NrJpanel = NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel();
        } else {
            NrJpanel = this.NrJpanel;
        }
        int lock = 0;
        int num = 0;
        if (type == 4 || type == 1) {
            lock = NrJpanel.getlock();
            num = lock % 10;
            lock = lock / 10;
        }
        BigDecimal xy = null;
        if (RoleData.getRoleData().getLoginResult().getGold().longValue() < money.longValue()) {
            GameJpanel.getGameJpanel().addPrompt("#Y金钱不足");
            return false;
        }
        if (num >4) {
        	GameJpanel.getGameJpanel().addPrompt("最多只能锁定4个");
        	return false;
        } else if (num > 0) {
            if (type == 4) {
                    //	xy = new BigDecimal(3000);
                //} 	else {
                //    xy = new BigDecimal(6000);
            }
            LianHua lianHua1 = UserMessUntil.getAllLianHua().get1000(num);
            LianHua lianHua2 = UserMessUntil.getAllLianHua().get2000(num);
            if (num == 1) {
                if (type == 4) {
                    xy = new BigDecimal(lianHua1.getMoney());
                } else {
                    xy = new BigDecimal(lianHua2.getMoney());
                }
            } else if (num == 2) {
                if (type == 4) {
                    xy = new BigDecimal(lianHua1.getMoney());
                } else {
                    xy = new BigDecimal(lianHua2.getMoney());
                }
            } else if (num == 3) {
                if (type == 4) {
                    xy = new BigDecimal(lianHua1.getMoney());
                } else {
                    xy = new BigDecimal(lianHua2.getMoney());
                }
            }else if (num == 4) {
                if (type == 4) {
                    xy = new BigDecimal(lianHua1.getMoney());
                } else {
                    xy = new BigDecimal(lianHua2.getMoney());
                }
            }

            LianHua lianHua = UserMessUntil.getAllLianHua().get1000(num);//炼器显示  正常 100仙玉..
            xy = new BigDecimal(lianHua.getMoney());
            if (RoleData.getRoleData().getLoginResult().getCodecard().longValue() < xy.longValue()) {
                GameJpanel.getGameJpanel().addPrompt("仙玉不足");
                return false;
            }
        }
    
        List<BigDecimal> rgids = new ArrayList<>();
        int size = 0;
        int p = -1;
        for (int i = 0; i < goods.length; i++) {
            if (goods[i] != null) {
                size++;
                p = i;
                if (goods[i].getGoodlock() == 1) {
                    ZhuFrame.getZhuJpanel().addPrompt("该物品已被加锁");
                    return false;
                }
                if (GoodsListFromServerUntil.isExist(goods[i])) {
                    return false;
                }
                int sum = 1;
                for (int j = 0; j < rgids.size(); j++) {
                    if (goods[i].getRgid().compareTo(rgids.get(j)) == 0) {
                        sum++;
                    }
                }
                if (sum > goods[i].getUsetime()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                    return false;
                }
                rgids.add(goods[i].getRgid());
            }
        }
        if (p + 1 != size) {
            GameJpanel.getGameJpanel().addPrompt("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
            return false;
        }
        SuitOperBean operBean = new SuitOperBean();
        if (type == 0) {
            if (size != 2) {
                GameJpanel.getGameJpanel().addPrompt("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
                return false;
            }
            String extra = AccessSuitMsgUntil.getExtra(goods[0].getValue(), "炼器属性");
            if (extra != null) {
                String[] extras = extra.split("&");
                if (Integer.parseInt(extras[1]) >= 5) {
                    FrameMessageChangeJpanel.addtext(6, "最大开光次数5", null, null);
                    return false;
                }
            }
            operBean.setType(10);
        } else if (type == 1) {
            if (size != 4) {
                GameJpanel.getGameJpanel().addPrompt("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
                return false;
            }
            String extra = AccessSuitMsgUntil.getExtra(goods[0].getValue(), "炼器属性");
            if (extra == null) {
                FrameMessageChangeJpanel.addtext(6, "先去开光", null, null);
                return false;
            }
            operBean.setType(11);
        } else if (type == 3) {
            if (size != 1) {
                GameJpanel.getGameJpanel().addPrompt("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
                return false;
            }
            operBean.setType(13);
        } else if (type == 4) {
            if (AccessSuitMsgUntil.getExtra(goods[0].getValue(), "套装属性") != null) {
                FrameMessageChangeJpanel.addtext(6, "套装无法炼化", null, null);
                return false;
            }
            if (Goodtype.GodEquipment_xian(goods[0].getType())||Goodtype.GodEquipment_Ding(goods[0].getType())) {
                if (goods[1].getType() == 7005) {// 仙器阶数
                    String god = Goodtype.StringParsing(goods[1].getValue())[1];
                    if (!god.equals("阶数=1")) {
                        FrameMessageChangeJpanel.addtext(6, "使用一阶作为炼化材料太掉价了吗?", null, null);
                        return false;
                    }
                } else if (Goodtype.GodEquipment_xian(goods[1].getType())||Goodtype.GodEquipment_Ding(goods[1].getType())) {
                    String god = Goodtype.StringParsing(goods[1].getValue())[0];
                    if (!god.equals("阶数=1")) {
                        FrameMessageChangeJpanel.addtext(6, "使用一阶作为炼化材料太掉价了吗?", null, null);
                        return false;
                    }
                }
            } else if (Goodtype.GodEquipment_God(goods[1].getType())) {
                    String god = Goodtype.StringParsing(goods[1].getValue())[0];
                    if (!god.equals("阶数=1")) {
                        FrameMessageChangeJpanel.addtext(6, "使用一阶作为炼化材料太掉价了吗?", null, null);
                        return false;
                    }
                }

//            operBean.getJade().set
            operBean.setType(14);
        }
        for (int i = 1; i < goods.length; i++) {
            if (goods[i] != null) {
                goods[i].goodxh(1);
                if (goods[i].getUsetime() <= 0) {
                    GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                }
            }
        }
        RoleData.getRoleData().getLoginResult()
                .setGold(RoleData.getRoleData().getLoginResult().getGold().subtract(money));
        if (xy != null) {
            RoleData.getRoleData().getLoginResult()
                    .setCodecard(RoleData.getRoleData().getLoginResult().getCodecard().subtract(xy));
            operBean.setJade(new PartJade(lock, 0));
            GoodDetailedJframe.getGoodDetailedJframe().getGoodDetailedJpanel().getYonghuXianyu()
                    .setText(RoleData.getRoleData().getLoginResult().getCodecard() + "");
            TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getJadeNum()
                    .setText(RoleData.getRoleData().getLoginResult().getCodecard() + "");
        }

        operBean.setGoods(rgids);// 发送消息给服务器
        //system.out.println(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
        return true;
    }

    public void cao2(Goodstable[] goods, BigDecimal money, String type, List<BigDecimal> rgids) {
        NpcComposeBean npcComposeBean = new NpcComposeBean();
        if (type.equals("佩饰重铸")) {
            // 饰品描述信息
            String Bottletext = goods[0].getValue();
            String[] gongneng = Goodtype.StringParsing(Bottletext);
            // 矿石等级
            int kslvl = Integer.parseInt(goods[1].getValue().split("=")[1]);
            if (DazaoBtn.Numerical(gongneng[0]) != (kslvl - 3)) {
                FrameMessageChangeJpanel.addtext(6, "请使用" + (DazaoBtn.Numerical(gongneng[0]) + 3) + "级矿石进行重铸!", null,
                        null);
                return;
            }
            npcComposeBean.setComposetype("我要重铸饰品");
            UserData.uptael(money.intValue());
            List<BigDecimal> goodstables = new ArrayList<>();
            for (int i = 0; i < goods.length; i++) {
                if (goods[i] != null) {
                    goodstables.add(goods[i].getRgid());
                    goods[i].goodxh(1);
                    if (goods[i].getUsetime() <= 0) {
                        GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                        eJpanel2.ClickGood(null, i + 24);
                    }
                }
            }
            npcComposeBean.setGoodstables(goodstables);
            String sendMes = Agreement.getAgreement().npccomposeAgreement(
                    GsonUtil.getGsonUtil().getgson().toJson(npcComposeBean));
            SendMessageUntil.toServer(sendMes);// 向服务器发送信息
        } else if (type.equals("护身符培养")) {
            String[] vs = goods[0].getValue().split("\\|");
            int pz = 0;
            for (int i = 0; i < vs.length; i++) {
                String[] vsz = vs[i].split("=");
                if (vsz[0].equals("品质")) {
                    pz = Integer.parseInt(vsz[1].split("/")[0]);
                    break;
                }
            }
            int up = 800;
            String extra = AccessSuitMsgUntil.getExtra(goods[0].getValue(), "炼化属性");
            if (extra != null) {
                String[] vvs = extra.split("&");
                s:
                for (int i = 0; i < vvs.length; i++) {
                    String[] vvvs = vvs[i].split("=");
                    if (vvvs[0].equals("特技")) {
                        for (int j = 1; j < vvvs.length; j++) {
                            if (vvvs[j].equals("8031")) {
                                up = 900;
                                break s;
                            }
                        }
                    }
                }
            }
            if (pz > up) {
                FrameMessageChangeJpanel.addtext(6, "该护身符品质大于" + up + "后无法培养", null, null);
                return;
            }
            npcComposeBean.setComposetype("我要培养护身符");
            UserData.uptael(money.intValue());
            List<BigDecimal> goodstables = new ArrayList<>();
            for (int i = 0; i < goods.length; i++) {
                if (goods[i] != null) {
                    goodstables.add(goods[i].getRgid());
                    goods[i].goodxh(1);
                    if (goods[i].getUsetime() <= 0) {
                        GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                        eJpanel2.ClickGood(null, i + 24);
                    }
                }
            }
            npcComposeBean.setGoodstables(goodstables);
            String sendMes = Agreement.getAgreement().npccomposeAgreement(
                    GsonUtil.getGsonUtil().getgson().toJson(npcComposeBean));
            SendMessageUntil.toServer(sendMes);// 向服务器发送信息
        } else if (type.equals("护身符重铸")) {
            String[] vs = goods[0].getValue().split("\\|");
            int pz = 0;
            for (int i = 0; i < vs.length; i++) {
                String[] vsz = vs[i].split("=");
                if (vsz[0].equals("品质")) {
                    pz = Integer.parseInt(vsz[1].split("/")[0]);
                    break;
                }
            }
            if (pz < 300) {
                FrameMessageChangeJpanel.addtext(6, "该护身符品质低于300的需要培养", null, null);
                return;
            }
            // 矿石等级
            int kslvl = Integer.parseInt(goods[1].getValue().split("=")[1]);
            if (kslvl != 9 && kslvl != 10) {
                FrameMessageChangeJpanel.addtext(6, "护身符重铸使用9级矿石,升级使用10级矿石", null, null);
                return;
            }
            npcComposeBean.setComposetype("我要重铸护身符");
            int lvl = Integer.parseInt(goods[0].getValue().split("\\|")[0].split("=")[1]);
            if (kslvl == 10) {
                lvl++;
                if (lvl > 10) {
                    FrameMessageChangeJpanel.addtext(6, "护身符等级最高为7级", null, null);
                    return;
                }
            }
            UserData.uptael(money.intValue());
            List<BigDecimal> goodstables = new ArrayList<>();
            for (int i = 0; i < goods.length; i++) {
                if (goods[i] != null) {
                    goodstables.add(goods[i].getRgid());
                    goods[i].goodxh(1);
                    if (goods[i].getUsetime() <= 0) {
                        GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                        eJpanel2.ClickGood(null, i + 24);
                    }
                }
            }
            npcComposeBean.setGoodstables(goodstables);
            String sendMes = Agreement.getAgreement().npccomposeAgreement(
                    GsonUtil.getGsonUtil().getgson().toJson(npcComposeBean));
            SendMessageUntil.toServer(sendMes);// 向服务器发送信息
        } else if (type.equals("彩晶石培养")) {
            npcComposeBean.setComposetype("培养彩晶石");
            UserData.uptael(money.intValue());
        List<BigDecimal> goodstables = new ArrayList<>();
        for (int i = 0; i < goods.length; i++) {
            if (goods[i] != null) {
                goodstables.add(goods[i].getRgid());
                goods[i].goodxh(1);
                if (goods[i].getUsetime() <= 0) {
                    GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                        eJpanel2.ClickGood(null, i + 24);
                }
            }
        }
        npcComposeBean.setGoodstables(goodstables);
        String sendMes = Agreement.getAgreement().npccomposeAgreement(
                GsonUtil.getGsonUtil().getgson().toJson(npcComposeBean));
        SendMessageUntil.toServer(sendMes);// 向服务器发送信息
        } else if (type.equals("巫铸")) {
            if (!Util.isCanBuyOrno()) {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                }
                for (int i = 0; i < 4; ++i) {
                    if (goods[i] == null) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                        return;
                    }
                    if (goods[i].getGoodlock() == 1) {
                        ZhuFrame.getZhuJpanel().addPrompt2("该物品已被加锁");
                        return;
                    }
                    if (GoodsListFromServerUntil.isExist(goods[i])) {
                        return;
                    }
                    if (Goodtype.EquipmentType(goods[i].getType().longValue()) != -1) {
                        if (AccessSuitMsgUntil.getExtra(goods[i].getValue(), BaptizeBtn.Extras[3]) != null) {
                            ZhuFrame.getZhuJpanel().addPrompt2("套装无法用于打造系列");
                            return;
                        }
                        if (AccessSuitMsgUntil.getExtra(goods[i].getValue(), BaptizeBtn.Extras[4]) != null || (goods[i].getQhv() != null && goods[i].getQhv().intValue() > 0)) {
                            ZhuFrame.getZhuJpanel().addPrompt2("已镶嵌宝石无法用于打造系列");
                            return;
                        }
                    }
                }

                if (!this.type(type, goods)) {
                    int zblvl=Integer.parseInt(goods[0].getValue().split("\\|")[0].split("=")[1]);//装备等级
                    int kslvl = Integer.parseInt(goods[1].getValue().split("=")[1]);
                    boolean up=false;
                    if (zblvl>=10&&zblvl<=13) {
                        if (kslvl!=8&&kslvl!=9) {return;}
                        else if (kslvl==9) {up=true;}
                    }else if (zblvl==14) {
                        if (kslvl!=9&&kslvl!=10) {return;}
                        else if (kslvl==10) {up=true;}
                    }else if (zblvl==15) {
                        if (kslvl!=10&&kslvl!=11) {return;}
                        else if (kslvl==11) {up=true;}
                    }else if (zblvl==16) {
                        if (kslvl!=11) {return;}
                    }else {
                        return;
                    }

                    zblvl = zblvl + (up ? 1 : 0);
                    int wzcl = 1;
                    String typeStr = getEquipType(goods[0].getType());
                    if (typeStr == "武器" || typeStr == "衣服" || typeStr == "帽子") {      //武器衣服帽子

                        if (zblvl == 15) {
                            wzcl = 4;
                        }
                        if (zblvl == 16) {
                            wzcl = 25;
                        }
                        if (zblvl == 15 && goods[3].getUsetime() < wzcl) {
                            ZhuFrame.getZhuJpanel().addPrompt2(goods[3].getGoodsname() + "材料数量不足！需要4个。");
                            return;
                        }
                        if (zblvl == 16 && goods[3].getUsetime() < wzcl) {
                            ZhuFrame.getZhuJpanel().addPrompt2(goods[3].getGoodsname() + "材料数量不足！需要25个。");
                            return;
                        }
                    } else if (typeStr == "鞋子" || typeStr == "项链") {       //鞋子项链
                        if (zblvl == 15) {
                            wzcl = 3;
                        }
                        if (zblvl == 16) {
                            wzcl = 16;
                        }

                        if (zblvl == 15 && goods[3].getUsetime() < wzcl) {
                            ZhuFrame.getZhuJpanel().addPrompt2(goods[3].getGoodsname() + "材料数量不足！需要3个。");
                            return;
                        }
                        if (zblvl == 16 && goods[3].getUsetime() < wzcl) {
                            ZhuFrame.getZhuJpanel().addPrompt2(goods[3].getGoodsname() + "材料数量不足！需要16个。");
                            return;
                        }
                    }

                    if (!type.equals("我要升级神兵") && !type.equals("精炼神兵")) {
                        UserData.uptael((long) money.intValue());
                        final List<BigDecimal> goodstables = (List<BigDecimal>) new ArrayList();
                        for (int j = 0; j < 4; j++) {
                            if (j == 0) {
                                goods[j].setUsetime(Integer.valueOf(0));
                            }
                            if (j != 0 && j != 3) {
                                goods[j].setUsetime(Integer.valueOf(goods[j].getUsetime().intValue() - 1));
                            }
                            else if(j == 3){
                                goods[j].setUsetime(Integer.valueOf(goods[j].getUsetime().intValue() - wzcl));
                            }
                            goodstables.add(goods[j].getRgid());
                            if (goods[j].getUsetime().intValue() <= 0) {
                                GoodsListFromServerUntil.Deletebiaoid(goods[j].getRgid());
                                goods[j] = null;
                                eJpanel.ClickGood(null, j + 24);
                            }
                        }
                        final WitchComposeBean witchComposeBean = new WitchComposeBean();
                        witchComposeBean.setComposetype(type);
                        witchComposeBean.setGoodstables(goodstables);
                        final String senmes = Agreement.getAgreement().witchcomposeAgreement(GsonUtil.getGsonUtil().getgson().toJson(witchComposeBean));
                        SendMessageUntil.toServer(senmes);
                    }
                }
            }
        } else if (type.equals("普通打造")) {
            //type.equals("11级装备产生锻造")||type.equals("12级装备产生锻造")||type.equals("13级装备产生锻造")||
            //        type.equals("14级装备产生锻造")||type.equals("15级装备产生锻造")||type.equals("16级装备产生锻造")
            if (!Util.isCanBuyOrno()) {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() < money.longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱不足");
                }
                else {
                    for (int i = 0; i < 2; ++i) {
                        if (goods[i] == null) {
                            ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                            return;
                        }
                        if (goods[i].getGoodlock() == 1) {
                            ZhuFrame.getZhuJpanel().addPrompt2("该物品已被加锁");
                            return;
                        }
                        if (GoodsListFromServerUntil.isExist(goods[i])) {
                            return;
                        }
                        if (Goodtype.EquipmentType(goods[i].getType().longValue()) != -1) {
                            if (AccessSuitMsgUntil.getExtra(goods[i].getValue(), BaptizeBtn.Extras[3]) != null) {
                                ZhuFrame.getZhuJpanel().addPrompt2("套装无法用于打造系列");
                                return;
                            }
                            if (AccessSuitMsgUntil.getExtra(goods[i].getValue(), BaptizeBtn.Extras[4]) != null || (goods[i].getQhv() != null && goods[i].getQhv().intValue() > 0)) {
                                ZhuFrame.getZhuJpanel().addPrompt2("已镶嵌宝石无法用于打造系列");
                                return;
                            }
                        }
                    }
                    if (!this.type(type, goods)) {
                            UserData.uptael((long)money.intValue());
                            final List<BigDecimal> goodstables = (List<BigDecimal>)new ArrayList();
                            for (int j = 0; j < 2; ++j) {
                                if (j == 0) {
                                    goods[j].setUsetime(Integer.valueOf(0));
                                }
                                else {
                                    goods[j].setUsetime(Integer.valueOf(goods[j].getUsetime().intValue() - 1));
                                }
                                goodstables.add(goods[j].getRgid());
                                if (goods[j].getUsetime().intValue() <= 0) {
                                    GoodsListFromServerUntil.Deletebiaoid(goods[j].getRgid());
                                    goods[j] = null;
                                    eJpanel.ClickGood(null, j + 24);
                                }
                            }
                            npcComposeBean.setComposetype("打造11级以上高级装备");
                            npcComposeBean.setGoodstables(goodstables);
                            final String senmes = Agreement.getAgreement().npccomposeAgreement(GsonUtil.getGsonUtil().getgson().toJson(npcComposeBean));
                            SendMessageUntil.toServer(senmes);
                    }
                }
            }
        } else {
            return;
        }
    }

    // 区分装备类型
    public static String getEquipType( Long type ){
        // 物品类型
        String goodsType = null;
        if((type==601)||(type==600)){
            goodsType = "帽子";// 帽子
        }else if((type==603)){
            goodsType = "项链";// 项链类型
        }else if((type==605)||(type==604)){
            goodsType = "衣服";// 衣服类型
        }else if((type==800)){
            goodsType = "武器";	// 武器类型
        }else if((type==602)){
            goodsType = "鞋子";// 鞋子类型
        }else if(type==612){// 护身符类型
            goodsType = "护身符";
        }
        return goodsType;
    }
    /** 一键佩饰培养 */
    public void cao3(Goodstable[] goods, BigDecimal money, List<BigDecimal> rgids) {
        int mxxh = goods[1].getUsetime();
        long sxm = RoleData.getRoleData().getLoginResult().getGold().longValue();
        if (sxm / money.longValue() < mxxh) {
            mxxh = (int) (sxm / money.longValue());
        }
        int xh = 0;
        String[] qs = goods[0].getValue().split("\\|");
        if (DazaoBtn.Numerical(qs[0]) >= 7) {
            ZhuFrame.getZhuJpanel().addPrompt2("还没开放8级佩饰培养");
            return;
        }
        if (Goodtype.Accessories(goods[1].getType())) {
            int flvl = 0;
            String[] vs = goods[1].getValue().split("\\|");
            for (int i = 0; i < vs.length; i++) {
                String[] v = vs[i].split("=");
                if (v[0].equals("等级")) {
                    flvl = Integer.parseInt(v[1]);
                }
            }
            if (flvl > 2) {
                ZhuFrame.getZhuJpanel().addPrompt2("无法用2级以上的配饰培养");
                return;
            }
        }
        int max = 0;
        for (int i = 0; i < qs.length; i++) {
            if (qs[i].length() >= 2 && qs[i].substring(0, 2).equals("培养")) {
                String[] num = qs[i].split("=")[1].split("/");
                int value = Integer.parseInt(num[0]);
                max = Integer.parseInt(num[1]);
                xh = max - value + 1;
            }
        }
        if (max == 0) {
            ZhuFrame.getZhuJpanel().addPrompt2("该配饰无法培养");
            return;
        }
        if (xh > mxxh) {
            xh = mxxh;
        }
        if (xh <= 0) {
            GameJpanel.getGameJpanel().addPrompt("#Y请凑齐物品再来");
            return;
        }
        money = new BigDecimal(money.longValue() * xh);
        if (RoleData.getRoleData().getLoginResult().getGold().longValue() < money.longValue()) {
            GameJpanel.getGameJpanel().addPrompt("#Y金钱不足");
            return;
        }
        ZhuFrame.getZhuJpanel().addPrompt2("一键培养了" + xh + "次");
        RoleData.getRoleData().getLoginResult()
                .setGold(RoleData.getRoleData().getLoginResult().getGold().subtract(money));

        SuitOperBean operBean = new SuitOperBean();
        PartJade jade = new PartJade(-1, -1);
        jade.setJade1(xh);
        operBean.setType(15);
        goods[0].setUsetime(0);
        GoodsListFromServerUntil.Deletebiaoid(goods[0].getRgid());
        eJpanel2.ClickGood(null, 24);
        goods[1].goodxh(xh);
        if (goods[1].getUsetime() <= 0) {
            GoodsListFromServerUntil.Deletebiaoid(goods[1].getRgid());
            eJpanel2.ClickGood(null, 25);
        }
        operBean.setJade(jade);
        operBean.setGoods(rgids);// 发送消息给服务器
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    private void cao4(Goodstable[] goods, BigDecimal money, String v, List<BigDecimal> rgids) {
        // TODO Auto-generated method stub
        SuitOperBean operBean = new SuitOperBean();
        if (v.equals("秘石合成")) {
            operBean.setType(36);
            int value = -1;
            for (int i = 0; i < goods.length; i++) {
                if (goods[i] == null) {
                    continue;
                }
                if (value == -1) {
                    value = Integer.parseInt(goods[i].getValue().split("=")[1]);
                } else if (value != Integer.parseInt(goods[i].getValue().split("=")[1])) {
                    ZhuFrame.getZhuJpanel().addPrompt2("使用等级相同的秘石合成");
                    return;
                }
            }
            if (value == -1) {
                return;
            }
            if (value >= 5) {
                ZhuFrame.getZhuJpanel().addPrompt2("最高5级");
                return;
            }
        }
        RoleData.getRoleData().getLoginResult()
                .setGold(RoleData.getRoleData().getLoginResult().getGold().subtract(money));
        for (int i = 0; i < goods.length; i++) {
            if (goods[i] != null) {
                goods[i].goodxh(1);
                if (goods[i].getUsetime() <= 0) {
                    GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                    eJpanel.ClickGood(null, i + 24);
                }
            }
        }
        operBean.setGoods(rgids);
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    public  boolean caozuo5(Goodstable[] goods, BigDecimal money,String type2){
        NewRefiningJpanel NrJpanel = null;
        if (this.NrJpanel == null) {
            NrJpanel = NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel();
        } else {
            NrJpanel = this.NrJpanel;
        }


        BigDecimal xy = null;
        if (RoleData.getRoleData().getLoginResult().getGold().longValue() < money.longValue()) {
            GameJpanel.getGameJpanel().addPrompt("#Y金钱不足");
            return false;
        }

        List<BigDecimal> rgids = new ArrayList<>();
        int size = 0;
        int p = -1;
        for (int i = 0; i < goods.length; i++) {
            if (goods[i] != null) {
                size++;
                p = i;
                if (goods[i].getGoodlock() == 1) {
                    ZhuFrame.getZhuJpanel().addPrompt("该物品已被加锁");
                    return false;
                }
                if (GoodsListFromServerUntil.isExist(goods[i])) {
                    return false;
                }
                int sum = 1;
                for (int j = 0; j < rgids.size(); j++) {
                    if (goods[i].getRgid().compareTo(rgids.get(j)) == 0) {
                        sum++;
                    }
                }
                if (sum > goods[i].getUsetime()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("请凑齐物品再来");
                    return false;
                }
                rgids.add(goods[i].getRgid());
            }
        }
        if (p + 1 != size) {
            GameJpanel.getGameJpanel().addPrompt("#Y请在引导界面查看公式,如果引导界面没有对应公式 联系管理员补充");
            return false;
        }
        SuitOperBean operBean = new SuitOperBean();

        for (int i = 1; i < goods.length; i++) {
            if (goods[i] != null) {
                goods[i].goodxh(1);
                if (goods[i].getUsetime() <= 0) {
                    GoodsListFromServerUntil.Deletebiaoid(goods[i].getRgid());
                }
            }
        }
        if (type2.equals("点翠"))
            operBean.setType(120);
        else operBean.setType(122);
        RoleData.getRoleData().getLoginResult()
                .setGold(RoleData.getRoleData().getLoginResult().getGold().subtract(money));

        operBean.setGoods(rgids);// 发送消息给服务器
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
        return true;

    }

    /**
     * 伙伴装备操作
     * 
     * @param goods
     * @param type
     *            0伙伴装备升级 1伙伴装备培养
     */
    public void palEquipUpgradeOrCultivate(Goodstable[] goods, String type) {
        String palEquipAgree = AccessSuitMsgUntil.getPalEquipAgree(goods[0].getValue(), "契合度");
        String[] split = palEquipAgree.split("=");
        String[] agreeArr = split[1].split("/");
        if ("装备升级".equals(type)) {
            if (Integer.parseInt(agreeArr[0]) < Integer.parseInt(agreeArr[1])) {
                // 契合度不够
                ZhuFrame.getZhuJpanel().addPrompt2("该装备契合度不够");
                return;
            }
        } else if ("装备培养".equals(type)) {
            if (Integer.parseInt(agreeArr[0]) >= Integer.parseInt(agreeArr[1])) {
                // 契合度不够
                ZhuFrame.getZhuJpanel().addPrompt2("该装备契合度已满");
                return;
            }
            if (Goodtype.isPalEquip(goods[1].getType())) {
                String levelEquip = AccessSuitMsgUntil.getPalEquipAgree(goods[1].getValue(), "等级");
                String[] lvlArr = levelEquip.split("=");
                if (Integer.parseInt(lvlArr[1]) >= 4) {
                    ZhuFrame.getZhuJpanel().addPrompt2("装备4级以上包括4级,不能作为培养道具");
                    return;
                }
            } else if (goods[1].getType() != 7511) {
                ZhuFrame.getZhuJpanel().addPrompt2("不是伙伴装备培养道具");
                return;
            }
        }
        SuitOperBean operBean = new SuitOperBean();
        List<BigDecimal> arrayList = new ArrayList<>();
        for (int i = 0; i < goods.length; i++) {
            if (goods[i] == null) {
                continue;
            }
            arrayList.add(goods[i].getRgid());
        }
        operBean.setGoods(arrayList);
        operBean.setType(62 - ("装备培养".equals(type) ? 1 : 0));
        String senmes = Agreement.suitOperateAgreement(GsonUtil.getGsonUtil().getgson().toJson(operBean));
        SendMessageUntil.toServer(senmes);
    }

    /**
     * 判断伙伴装备升级需要的矿石等级
     * 
     * @param agreeMax
     * @return
     */
    public String isBooleanEquipLvl(String agreeMax) {
        if ("1000".equals(agreeMax)) {
            return "2";
        } else if ("2000".equals(agreeMax)) {
            return "3";
        } else if ("4000".equals(agreeMax)) {
            return "4";
        } else if ("6000".equals(agreeMax)) {
            return "5";
        } else if ("8000".equals(agreeMax)) {
            return "6";
        }
        return "-1";
    }
    public boolean type(final String type, final Goodstable[] goods) {
        if (type != null) {
            if (type.equals("巫铸")) {
                return this.GoodItemWuzhu(goods);
            }else if(type.equals("普通打造")){
                return this.GoodItem_4(goods);
            }
        }
        return true;
    }

    public boolean GoodItemWuzhu(final Goodstable[] goods) {
        final int goodid = goods[0].getGoodsid().intValue();
        final int zblvl = Integer.parseInt(goods[0].getValue().split("\\|")[0].split("=")[1]);
        final int kslvl = Integer.parseInt(goods[1].getValue().split("=")[1]);
        if (zblvl < 10) {
            FrameMessageChangeJpanel.addtext(6, "巫铸装备只能为11~16级装备!", null, null);
            return true;
        }
        boolean up = false;
        if (zblvl >= 10 && zblvl <= 13) {
            if (/*kslvl != 8 &&*/ kslvl != 9) {
                FrameMessageChangeJpanel.addtext(6, "巫铸11-14级装备使用9级矿石!", null, null);
            //    FrameMessageChangeJpanel.addtext(6, "重铸11-13级装备使用8级矿石!", null, null);
                return true;
            }
            if (kslvl == 9) {
                up = true;
            }
        }
        else if (zblvl == 14) {
            if (kslvl != 9 && kslvl != 10) {
                FrameMessageChangeJpanel.addtext(6, "巫铸15级装备使用10级矿石!", null, null);
                FrameMessageChangeJpanel.addtext(6, "重铸14级装备使用9级矿石!", null, null);
                return true;
            }
            if (kslvl == 10) {
                up = true;
            }
        }
        else if (zblvl == 15) {
            if (kslvl != 10 && kslvl != 11) {
                FrameMessageChangeJpanel.addtext(6, "巫铸16级装备使用11级矿石!", null, null);
                FrameMessageChangeJpanel.addtext(6, "重铸15级装备使用10级矿石!", null, null);
                return true;
            }
            if (kslvl == 11) {
                up = true;
            }
        }
        else {
            if (zblvl != 16) {
                FrameMessageChangeJpanel.addtext(6, "错误公式", null, null);
                return true;
            }
            if (kslvl != 11) {
                FrameMessageChangeJpanel.addtext(6, "重铸16级装备使用11级矿石!", null, null);
                return true;
            }
        }
        return false;
    }

    public boolean GoodItem_4(final Goodstable[] goods) {
        final int goodid = goods[0].getGoodsid().intValue();
        final int zblvl = Integer.parseInt(goods[0].getValue().split("\\|")[0].split("=")[1]);
        final int kslvl = Integer.parseInt(goods[1].getValue().split("=")[1]);
        if (zblvl < 10) {
            FrameMessageChangeJpanel.addtext(6, "打造1-10级装备去长安城打铁铺找冯铁匠!", null, null);
            return true;
        }
        boolean up = false;
        if (zblvl >= 10 && zblvl <= 13) {
            if (/*kslvl != 8 && */kslvl != 9) {
                FrameMessageChangeJpanel.addtext(6, "打造11-14级装备使用9级矿石!", null, null);
            //   FrameMessageChangeJpanel.addtext(6, "重铸11-13级装备使用8级矿石!", null, null);
                return true;
            }
            if (kslvl == 9) {
                up = true;
            }
        }
        else if (zblvl == 14) {
            if (kslvl != 9 && kslvl != 10) {
                FrameMessageChangeJpanel.addtext(6, "打造15级装备使用10级矿石!", null, null);
                FrameMessageChangeJpanel.addtext(6, "重铸14级装备使用9级矿石!", null, null);
                return true;
            }
            if (kslvl == 10) {
                up = true;
            }
        }
        else if (zblvl == 15) {
            if (kslvl != 10 && kslvl != 11) {
                FrameMessageChangeJpanel.addtext(6, "打造16级装备使用11级矿石!", null, null);
                FrameMessageChangeJpanel.addtext(6, "重铸15级装备使用10级矿石!", null, null);
                return true;
            }
            if (kslvl == 11) {
                up = true;
            }
        }
        else {
            if (zblvl != 16) {
                FrameMessageChangeJpanel.addtext(6, "错误公式", null, null);
                return true;
            }
            if (kslvl != 11) {
                FrameMessageChangeJpanel.addtext(6, "重铸16级装备使用11级矿石!", null, null);
                return true;
            }
        }
        return false;
    }

}
